package day230920;

import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/9/20 18:33
 * 二分, 返回数组中 target 的最小索引
 */
public class Solution01 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // 数组长度
        int[] nums = new int[n]; // 录入的数组
        int target = in.nextInt(); // 期望查找的值
        // 录入数组
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        // 二分查找
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int mid = (left + right) / 2;
            if (nums[mid] < target) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        // 打印结果
        if (nums[left] == target) {
            System.out.println(left);
        } else {
            System.out.println(-1);
        }
        in.close();
    }
}
